home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Informant Complete 1995 - 2000
/
Delphi Informant Complete 1995 to 2000.iso
/
Delphi Informant Magazine Complete Works SOURCE CODE 1998.rar
/
1998
/
Sep
/
di9809jp
/
BlastClient
/
Winsock2.pas
< prev
Wrap
Pascal/Delphi Source File
|
1998-01-26
|
59KB
|
1,715 lines
{*******************************************************}
{ }
{ Windows Sockets API v. 2.20 Header File }
{ }
{ Prerelease 16.09.96 }
{ }
{ Base: WinSock2.h from Winsock SDK 1.6 BETA }
{ Delphi 2 RTL Windows32 API Interface }
{ }
{ (c) 1996 by Artur Grajek 'AHS' }
{ email: c51725ag@juggernaut.eti.pg.gda.pl }
{*******************************************************}
{ }
{ }
{ List of Modifications : }
{ Removed WS2's type definition of TGUID, and now use }
{ the TGUID type as defined in the D3's COMOBJ unit }
{ Modified by JCP 271197 }
{ }
{ }
{ }
{*******************************************************}
unit WinSock2;
interface
uses Windows, comobj;// Added COMOBJ for TGUID type reference JCP 271197
type
u_char = Char;
u_short = Word;
u_int = Integer;
u_long = Longint;
pu_long = ^u_long;
pu_short = ^u_short;
{ The new type to be used in all
instances which refer to sockets. }
TSocket = u_int;
const
FD_SETSIZE = 64;
type
PFDSet = ^TFDSet;
TFDSet = packed record
fd_count: u_int;
fd_array: array[0..FD_SETSIZE-1] of TSocket;
end;
PTimeVal = ^TTimeVal;
TTimeVal = packed record
tv_sec: Longint;
tv_usec: Longint;
end;
const
IOCPARM_MASK = $7f;
IOC_VOID = $20000000;
IOC_OUT = $40000000;
IOC_IN = $80000000;
IOC_INOUT = (IOC_IN or IOC_OUT);
FIONREAD = IOC_OUT or { get # bytes to read }
((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
(Longint(Byte('f')) shl 8) or 127;
FIONBIO = IOC_IN or { set/clear non-blocking i/o }
((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
(Longint(Byte('f')) shl 8) or 126;
FIOASYNC = IOC_IN or { set/clear async i/o }
((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
(Longint(Byte('f')) shl 8) or 125;
const
{ Protocols }
IPPROTO_IP = 0; { Dummy }
IPPROTO_ICMP = 1; { Internet Control Message Protocol }
IPPROTO_IGMP = 2; { Internet Group Management Protocol}
IPPROTO_GGP = 3; { Gateway }
IPPROTO_TCP = 6; { TCP }
IPPROTO_PUP = 12; { PUP }
IPPROTO_UDP = 17; { User Datagram Protocol }
IPPROTO_IDP = 22; { XNS IDP }
IPPROTO_ND = 77; { UNOFFICIAL Net Disk Protocol }
IPPROTO_RAW = 255;
IPPROTO_MAX = 256;
{ Port/socket numbers: network standard functions}
IPPORT_ECHO = 7;
IPPORT_DISCARD = 9;
IPPORT_SYSTAT = 11;
IPPORT_DAYTIME = 13;
IPPORT_NETSTAT = 15;
IPPORT_FTP = 21;
IPPORT_TELNET = 23;
IPPORT_SMTP = 25;
IPPORT_TIMESERVER = 37;
IPPORT_NAMESERVER = 42;
IPPORT_WHOIS = 43;
IPPORT_MTP = 57;
{ Port/socket numbers: host specific functions }
IPPORT_TFTP = 69;
IPPORT_RJE = 77;
IPPORT_FINGER = 79;
IPPORT_TTYLINK = 87;
IPPORT_SUPDUP = 95;
{ UNIX TCP sockets }
IPPORT_EXECSERVER = 512;
IPPORT_LOGINSERVER = 513;
IPPORT_CMDSERVER = 514;
IPPORT_EFSSERVER = 520;
{ UNIX UDP sockets }
IPPORT_BIFFUDP = 512;
IPPORT_WHOSERVER = 513;
IPPORT_ROUTESERVER = 520;
{ Ports < IPPORT_RESERVED are reserved for
privileged processes (e.g. root). }
IPPORT_RESERVED = 1024;
{ Link numbers }
IMPLINK_IP = 155;
IMPLINK_LOWEXPER = 156;
IMPLINK_HIGHEXPER = 158;
type
SunB = packed record
s_b1, s_b2, s_b3, s_b4: u_char;
end;
SunW = packed record
s_w1, s_w2: u_short;
end;
PInAddr = ^TInAddr;
TInAddr = packed record
case integer of
0: (S_un_b: SunB);
1: (S_un_w: SunW);
2: (S_addr: u_long);
end;
PSockAddrIn = ^TSockAddrIn;
TSockAddrIn = packed record
case Integer of
0: (sin_family: u_short;
sin_port: u_short;
sin_addr: TInAddr;
sin_zero: array[0..7] of Char);
1: (sa_family: u_short;
sa_data: array[0..13] of Char)
end;
type
PHostEnt = ^THostEnt;
THostEnt = packed record
h_name: PChar;
h_aliases: ^PChar;
h_addrtype: Smallint;
h_length: Smallint;
case integer of
0: (h_addr_list: ^PChar);
1: (h_addr: ^PInAddr);
end;
PNetEnt = ^TNetEnt;
TNetEnt = packed record
n_name: PChar;
n_aliases: ^PChar;
n_addrtype: Smallint;
n_net: u_long;
end;
PServEnt = ^TServEnt;
TServEnt = packed record
s_name: PChar;
s_aliases: ^PChar;
s_port: Smallint;
s_proto: PChar;
end;
PProtoEnt = ^TProtoEnt;
TProtoEnt = packed record
p_name: PChar;
p_aliases: ^Pchar;
p_proto: Smallint;
end;
const
INADDR_ANY = $00000000;
INADDR_LOOPBACK = $7F000001;
INADDR_BROADCAST = $FFFFFFFF;
INADDR_NONE = $FFFFFFFF;
ADDR_ANY = INADDR_ANY;
const
WSADESCRIPTION_LEN = 256;
WSASYS_STATUS_LEN = 128;
type
PWSAData = ^TWSAData;
TWSAData = packed record
wVersion: Word;
wHighVersion: Word;
szDescription: array[0..WSADESCRIPTION_LEN] of Char;
szSystemStatus: array[0..WSASYS_STATUS_LEN] of Char;
iMaxSockets: Word;
iMaxUdpDg: Word;
lpVendorInfo: PChar;
end;
PTransmitFileBuffers = ^TTransmitFileBuffers;
TTransmitFileBuffers = packed record
Head: Pointer;
HeadLength: DWORD;
Tail: Pointer;
TailLength: DWORD;
end;
const
{ Options for use with [gs]etsockopt at the IP level. }
(*
IP_OPTIONS = 1;
IP_MULTICAST_IF = 2; { set/get IP multicast interface }
IP_MULTICAST_TTL = 3; { set/get IP multicast timetolive }
IP_MULTICAST_LOOP = 4; { set/get IP multicast loopback }
IP_ADD_MEMBERSHIP = 5; { add an IP group membership }
IP_DROP_MEMBERSHIP = 6; { drop an IP group membership }
IP_DEFAULT_MULTICAST_TTL = 1; { normally limit m'casts to 1 hop }
IP_DEFAULT_MULTICAST_LOOP = 1; { normally hear sends if a member }
{ per socket; must fit in one mbuf }
*)
//
IP_OPTIONS = 1; //* set/get IP options */
IP_HDRINCL = 2; //* header is included with data */
IP_TOS = 3; //* IP type of service and preced*/
IP_TTL = 4; //* IP time to live */
IP_MULTICAST_IF = 9; //* set/get IP multicast i/f */
IP_MULTICAST_TTL = 10; //* set/get IP multicast ttl */
IP_MULTICAST_LOOP = 11; //*set/get IP multicast loopback */
IP_ADD_MEMBERSHIP = 12; //* add an IP group membership */
IP_DROP_MEMBERSHIP = 13; //* drop an IP group membership */
IP_DONTFRAGMENT = 14; //* don't fragment IP datagrams */
// Option to use with [gs]etsockopt at the IPPROTO_UDP level */
UDP_NOCHECKSUM = 1;
//* Option to use with [gs]etsockopt at the IPPROTO_TCP level */
TCP_EXPEDITED_1122 = $0002;
{ This is used instead of -1, since the
TSocket type is unsigned.}
INVALID_SOCKET = TSocket(NOT(0));
SOCKET_ERROR = -1;
{ The following may be used in place of the address family, socket type, or
protocol in a call to WSASocket to indicate that the corresponding value
should be taken from the supplied WSAPROTOCOL_INFO structure instead of the
parameter itself.
}
FROM_PROTOCOL_INFO = -1;
{ Types }
SOCK_STREAM = 1; { stream socket }
SOCK_DGRAM = 2; { datagram socket }
SOCK_RAW = 3; { raw-protocol interface }
SOCK_RDM = 4; { reliably-delivered m